/*
 * @Description: 
 * @Author: WuShiKang
 * @Date: 2021-04-13 21:33:19
 * @LastEditors: WuShiKang
 * @LastEditTime: 2021-04-15 00:37:35
 */
import axios,{get,post} from '@/utils/request.js'
// import {post} from '@/utils/request.js'
export default {
  namespaced:true,
  state:{
    UserManageData:[],
    total:0
  },
  getters:{},
  mutations:{
    changeUserManageData(state,payload){
      payload.data.list.forEach(function(item,index){
        if(item.gender=="male"){
          item.gender="女";
        }
        else{
          item.gender="男";
        }
      });
      state.UserManageData = payload.data.list;
      state.total=payload.data.total;
    }
  },
  actions:{
    findAllUserManage({commit},payload){
      let obj={
        page:1,
        pageSize:6
    }
    if(payload)
    {
      get('/baseUser/pageQuery',payload)
      .then(res => {
          console.log(res)
          commit('changeUserManageData',res);
      })
    }
    else{
      get('/baseUser/pageQuery',obj)
      .then(res => {
          console.log(res)
          commit('changeUserManageData',res);
      })
    }
    },
    async saveOrUpdataUserManage({dispatch},payload){
     let res =  await post('/baseUser/saveOrUpdate',payload);
       console.log(res);
      return res;
    },
   async deleteById(store,payload){
      return await get('/baseUser/deleteById',payload);
    },
    async setRoles(store,payload){
      return await pot('/baseUser/setRoles',payload);
    }
  }
}
